/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package logica.cliente;

import java.rmi.Naming;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.logging.Level;
import java.util.logging.Logger;
import presentacion.MensajeGlobal;
import presentacion.Chat;

/**
 *
 * @author abel
 */
public class ClienteRMI {
    static Chat principal;
    
    
    public static void main(String[] args) {
                
        principal = new Chat();
        principal.setVisible(true);
        
		try {
                    Registry registry = null;
                    ClienteRMIimplementor ejecutar= new ClienteRMIimplementor(principal);
                 
                   try{
                    
            //Creando la instancia del objeto
            //Inicializando el registro RMI
                  
           registry = LocateRegistry.getRegistry(1099);//use any no. less than 55000
            registry.list(); 
                    }catch (RemoteException e) { 
               registry = LocateRegistry.createRegistry(1099);
}
           //LocateRegistry.createRegistry(1099);
            
            
            //Enlazando el objeto con el registro RMI
            Naming.rebind("info", ejecutar);
            System.out.println("Objeto enlazado");
    } catch (Exception e) {
			e.printStackTrace();
                        
		}
}
   
    
    
    
}
